﻿/*  Copyright 2012 PerceiveIT Limited
 *  This file is part of the Scryber library.
 *
 *  You can redistribute Scryber and/or modify 
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  Scryber is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 * 
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with Scryber source code in the COPYING.txt file.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using Scryber.Drawing;

namespace Scryber.Styles.Old
{

    [PDFParsableComponent("Badge")]
    [TypeConverter(typeof(ExpandableObjectConverter))]
    public class PDFScryberBadgeStyle : PDFStyleItem
    {

        public static readonly PDFUnit DefaultXOffset = new PDFUnit(10,PageUnits.Millimeters);
        public static readonly PDFUnit DefaultYOffset = new PDFUnit(10,PageUnits.Millimeters);
        public const Reversible DefaultDisplayOption = Reversible.WhiteOnBlack;
        

        #region ctor(s)

        public PDFScryberBadgeStyle()
            : this(PDFObjectTypes.StyleBadge, false)
        {
        }

        protected PDFScryberBadgeStyle(PDFObjectType type, bool inherited)
            : base(type, inherited)
        {
        }

        #endregion


        [Obsolete("Scryber no longer supports the size adjustment of the badge", false)]
        [PDFAttribute("width")]
        public PDFUnit Width
        {
            get
            {
                return PDFUnit.Empty;
            }
            set
            {
                ;
            }
        }

        public void RemoveWidth()
        {
            this.Remove(StyleKeys.WidthAttr);
        }

        [Obsolete("Scryber no longer supports the size adjustment of the badge", false)]
        [PDFAttribute("height")]
        public PDFUnit Height
        {
            get
            {
                return PDFUnit.Empty;
            }
            set
            {
                ;
            }
        }

        public void RemoveHeight()
        {
            this.Remove(StyleKeys.HeightAttr);
        }

        [PDFAttribute("corner")]
        public Corner Corner
        {
            get
            {
                object val;
                if (this.GetEnumValue(StyleKeys.CornerAttr, typeof(Corner), false, out val))
                    return (Corner)val;
                else
                    return Corner.BottomRight;
            }
            set
            {
                this.SetValue(StyleKeys.CornerAttr, value);
            }
        }

        public void RemoveCorner()
        {
            this.Remove(StyleKeys.CornerAttr);
        }

        [PDFAttribute("display")]
        public Reversible DisplayOption
        {
            get
            {
                object val;
                if (this.GetEnumValue(StyleKeys.DisplayOptionAttr, typeof(Reversible), false, out val))
                    return (Reversible)val;
                else
                    return DefaultDisplayOption;
            }
            set
            {
                this.SetValue(StyleKeys.DisplayOptionAttr, value);
            }

        }

        public void RemoveDisplayOption()
        {
            this.Remove(StyleKeys.DisplayOptionAttr);
        }

        [PDFAttribute("x-offset")]
        public PDFUnit XOffset
        {
            get
            {
                PDFUnit val;
                if (this.GetUnitValue(StyleKeys.XOffsetAttr, false, out val))
                    return val;
                else
                    return DefaultXOffset;
            }
            set
            {
                if (value < 0)
                    value = 0;
                else if (value > 100)
                    value = 100;

                this.SetValue(StyleKeys.XOffsetAttr, value);
            }
        }

        public void RemoveXOffset()
        {
            this.Remove(StyleKeys.XOffsetAttr);
        }

        [PDFAttribute("y-offset")]
        public PDFUnit YOffset
        {
            get
            {
                PDFUnit val;
                if (this.GetUnitValue(StyleKeys.YOffsetAttr, false, out val))
                    return val;
                else
                    return DefaultYOffset;
            }
            set
            {
                if (value < 0)
                    value = 0;
                else if (value > 100)
                    value = 100;

                this.SetValue(StyleKeys.YOffsetAttr, value);
            }
        }

        public void RemoveYOffset()
        {
            this.Remove(StyleKeys.YOffsetAttr);
        }
    }
}
